#define _CRT_SECURE_NO_WARNINGS 1
class Solution {
public:
    void helper(TreeNode* root, string str, vector<string>& v) {
        if (root == nullptr)
            return;
        str += to_string(root->val);
        if (root->left == nullptr && root->right == nullptr) {
            v.push_back(str);
            return;
        }
        str += "->";

        helper(root->left, str, v);

        helper(root->right, str, v);


    }
    vector<string> binaryTreePaths(TreeNode* root) {
        string str;
        vector<string> v;
        helper(root, str, v);
        return v;
    }
};